<%--
  Created by IntelliJ IDEA.
  User: fire'ge
  Date: 2022/5/8
  Time: 20:25
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" isELIgnored="false" %>
<html>
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="/TakeawaySystem/css/login.css">
    <title>登录系统</title>
</head>
<body>

<div>

        <table id="table_container">
            <th id="th_size" colspan="3">欢 迎 登 录</th>
            <form id="reg-Form" method="get" action="../user/forward">
            <tr>
                <td>邮箱</td>
                <td><input type="text" name="username" id="username" >
                    <br>
                    <span id="username_err" class="err_meg" style="display: none">请输入邮箱正确格式</span>
                </td>
            </tr>
            <tr>
                <td>验证码</td>
                <td><input type="text" name="password" id="mailCode"  >
                    <br>
                    <span id="pwd_err" class="err_meg" style="display: none">验证码不能为空</span></td>

            </tr>
                <tr>
                    <td colspan="2"><input type="submit" id="getCode" name="get" value="获 取 验 证 码" class="button"></td>
                </tr>
            <tr>
                <td colspan="2"> <input type="submit" id="login" name="log" value="登录" class ="button"></td>
            </tr>

            </form>
            <tr>
                <td colspan="2"><a href="UserCenter.jsp">游客浏览</a> </td>

            </tr>
        </table>


</div>
</body>
<script Language="JavaScript">
    let username = document.getElementById("username");
    let err = document.getElementById("username_err");
    username.onblur = checkUsername;
    function checkUsername() {
        var un = username.value ;
        var reg = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$;
        var flag = reg.test(un)
        if (flag){
            err.style.display = "";
        }
        else {
            err.style.display = "none";
        }
        return !flag;
    }

    var password = document.getElementById("password");
    var err2 = document.getElementById("pwd_err");
    password.onblur = checkPwd;
    function checkPwd() {
        var pwd = password.value ;
        var reg = /^\d{0}$/;
        var flag = reg.test(pwd);
        if (flag){
            err2.style.display = "";
        }
        else {
            err2.style.display = "none";
        }
        return !flag;
    }


</script>
</html>